package com.serwis.app.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name="T_CAR")
public class Car implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	
	private int carId;
	private Customer customer;
	private String mark;
	private String type;
	private String yearOfProduction;
	private Set<Reservation> reservations = new HashSet<Reservation>();

	public Car() {
	}

	public Car(Customer klient, String mark, String type) {
		this.customer = klient;
		this.mark = mark;
		this.type = type;
	}

	public Car(Customer customer, String mark, String type, String yearOfProduction) {
		this.customer = customer;
		this.mark = mark;
		this.type = type;
		this.yearOfProduction = yearOfProduction;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="CAR_ID",unique = true, nullable = false)
	public int getCarId() {
		return this.carId;
	}

	public void setCarId(int carId) {
		this.carId = carId;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CAR_CUSTOMER_ID", nullable = false)
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name="MARK", nullable=false)
	public String getMark() {
		return this.mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}

	@Column(name="TYPE", nullable=false)
	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name="YEAR_OF_PRODUCTION", nullable=true)
	public String getYearOfProduction() {
		return this.yearOfProduction;
	}

	public void setYearOfProduction(String yearOfProduction) {
		this.yearOfProduction = yearOfProduction;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "car", cascade = CascadeType.ALL)
	public Set<Reservation> getReservations() {
		return reservations;
	}

	public void setReservations(Set<Reservation> reservations) {
		this.reservations = reservations;
	}

	
}
